﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class FormUsuarios : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            comboPersonal.DataSource = PersonasBLL.GetAll();
            comboPersonal.DataTextField = "SNombre";
            comboPersonal.DataValueField = "IPersona_id";
            comboPersonal.DataBind();

            comboRol.DataSource = RolesBLL.GetAll();
            comboRol.DataTextField = "SNombre";
            comboRol.DataValueField = "IRol_id";
            comboRol.DataBind();
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string nombreusuario = txtUser.Text;
        string password = txtPassw.Text;
        string combopersona = comboPersonal.SelectedValue;
        string comborol = comboRol.SelectedValue;

        UsuariosBLL.InsertarUsuarios(nombreusuario, password, Convert.ToInt32(combopersona), Convert.ToInt32(comborol));

        txtUser.Text = "";
        txtPassw.Text = "";
        grdvUsuarios.DataBind();
    }
}